package com.rain.rainspringboot3.encryption.entity;


import com.rain.rainspringboot3.desensitize.core.regex.annotation.EmailDesensitize;
import com.rain.rainspringboot3.desensitize.core.slider.annotation.IdCardDesensitize;
import com.rain.rainspringboot3.desensitize.core.slider.annotation.MobileDesensitize;
import com.rain.rainspringboot3.encryption.annotation.EncryptField;
import com.rain.rainspringboot3.encryption.enums.DataType;
import com.rain.rainspringboot3.encryption.factory.AESEncryptFactory;
import com.rain.rainspringboot3.encryption.factory.RSAEncryptFactory;
import com.rain.rainspringboot3.encryption.factory.SM4EncryptFactory;
import lombok.Data;

/**
 * 用户数据传输对象
 * 包含需要加密的敏感字段注解
 */
@Data
public class UserDTO {

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 手机号 - 使用SpEL表达式动态生成前缀
     */
    @EncryptField(
            type = DataType.PHONE,
            cacheable = true,
            cacheExpire = 600L,
            factory = RSAEncryptFactory.class,
            encrypt = false
    )
    @MobileDesensitize
    private String phone;

    /**
     * 身份证号
     */
    @EncryptField(
            type = DataType.ID_CARD,
            factory = SM4EncryptFactory.class,
            encrypt = true
    )
    @IdCardDesensitize
    private String idCard;

    /**
     * 邮箱
     */
    @EncryptField(type = DataType.EMAIL)
    @EmailDesensitize
    private String email;

    /**
     * 租户编码
     */
    private String tenantCode;

    /**
     * 版本号
     */
    private String version;
}